<?php

namespace app\parking\service;

use think\facade\Db;

class AdminService
{
    public static function manageCompany($data)
    {
        // 示例逻辑：更新或插入公司免费停车时长
        $company = Db::name('parking_company')->updateOrInsert(['name' => $data['name']], ['free_parking_time' => $data['free_parking_time']]);
        return ['status' => 'success', 'data' => $company];
    }

    public static function manageVisitor($data)
    {
        // 示例逻辑：为访客车辆分配免费停车时长
        $visitor = Db::name('parking_visitor')->updateOrInsert(['plate_number' => $data['plate_number']], ['company_id' => $data['company_id'], 'allocated_time' => $data['allocated_time']]);
        return ['status' => 'success', 'data' => $visitor];
    }

    public static function manageEmployee($data)
    {
        // 示例逻辑：绑定员工车牌号
        $employee = Db::name('parking_employee')->updateOrInsert(['plate_number' => $data['plate_number']], ['company_id' => $data['company_id']]);
        return ['status' => 'success', 'data' => $employee];
    }

    public static function getStats()
    {
        // 示例逻辑：获取统计数据
        $stats = Db::name('parking_parking')->select();
        return ['status' => 'success', 'data' => $stats];
    }
}
